package com.vm.osm.business.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.vm.osm.business.dao.EamStaffInfoMapper;
import com.vm.osm.business.dto.rsp.RspStaffPage;
import com.vm.osm.business.dto.rsp.StaffPage;
import com.vm.osm.business.entity.EamStaffInfo;
import com.vm.osm.business.service.IStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhangshilin on 2018/1/7.
 */
@Service
public class StaffInfoServiceImpl implements IStaffService {
    @Autowired
    private EamStaffInfoMapper eamStaffInfoMapper;

    @Override
    public int deleteByPrimaryKey(String id) {
        return eamStaffInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(EamStaffInfo record) {
        return eamStaffInfoMapper.insert(record);
    }

    @Override
    public int insertSelective(EamStaffInfo record) {
        return eamStaffInfoMapper.insertSelective(record);
    }

    @Override
    public EamStaffInfo selectByPrimaryKey(String id) {
        return eamStaffInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(EamStaffInfo record) {
        return eamStaffInfoMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(EamStaffInfo record) {
        return eamStaffInfoMapper.updateByPrimaryKey(record);
    }

    @Override
    public RspStaffPage findPage(Integer pageNum, Integer pageSize, String enterprise_name, String search) {
        RspStaffPage rspStaffPage = new RspStaffPage();
        Page page = PageHelper.startPage(pageNum,pageSize,true);
        List<StaffPage> dataList = eamStaffInfoMapper.findPage(enterprise_name,search);
        rspStaffPage.setData_list(dataList);
        rspStaffPage.setTotal_num(page.getTotal());
        rspStaffPage.setPage_num(page.getPageNum());
        rspStaffPage.setPage_size(page.getPageSize());
        return rspStaffPage;
    }
}
